<template>
  <div class="app-container">
    <el-form ref="user" :model="user" label-width="80px">
      <el-form-item label="姓名">
        <el-input v-model="user.name" />
      </el-form-item>
      <el-form-item label="账号">
        <el-input v-model="user.username" :disabled="true" />
      </el-form-item>
      <!--      <el-form-item label="手机号">-->
      <!--        <el-input v-model="user.mobile" />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="邮箱">-->
      <!--        <el-input v-model="user.mail" />-->
      <!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" @click="onSubmit">保存</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { adminSelfEdit } from '@/api/admin'
export default {
  name: 'Dashboard',
  data() {
    return {
      user: {
        name: this.$store.state.user.name,
        username: this.$store.state.user.username,
        id: this.$store.state.user.id,
        mail: this.$store.state.user.mail,
        mobile: this.$store.state.user.mobile
      }
    }
  },
  created() {
  },
  methods: {
    onSubmit() {
      adminSelfEdit(this.user).then(response => {
        if (response.code === 200) {
          this.$message({
            type: 'success',
            message: '管理员编辑成功'
          })
        } else {
          this.$message({
            type: 'error',
            message: response.message
          })
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
